package com.common.sdk.net.connect.http.center.tools;

import com.android.sohu.sdk.common.toolbox.LogUtils;
import com.common.sdk.net.connect.http.DaylilyRequest;

import okhttp3.Request;

public class HttpLog {
    private static final String TAG = "SohuOKHttp";

    public static void debug(String msg) {
        LogUtils.d(TAG, "" + msg);
    }

    public static void debug(Request request, String msg) {
        LogUtils.d(TAG + getRequestTag(request), "" + msg);
    }

    public static void error(Throwable e) {
        if (e != null) {
            LogUtils.e(TAG, e.toString(), e);
        }
    }

    public static void error(Request request, String msg) {
        LogUtils.e(TAG + getRequestTag(request), msg);
    }

    public static void error(Request request, Throwable e) {
        if (e != null) {
            LogUtils.e(TAG + getRequestTag(request), e.toString(), e);
        }
    }

    public static void error(Request request, String msg,  Throwable e) {
        LogUtils.e(TAG + getRequestTag(request), msg, e);
    }

    private static String getRequestTag(Request request) {
        if (request == null) {
            return "_null";
        }
        return "_" + request.url().encodedPath() + "_" + request.hashCode();
    }

}
